package com.tchintech.pay.utils;

/**
 * Created by Administrator on 2017/9/22 0022.
 */

import android.content.Context;
import android.os.Handler;
import android.os.Message;

import com.tchintech.pay.model.entity.HttpCode;
import com.tchintech.pay.net.OkhttpClientTest;

import java.util.HashMap;
import java.util.Map;

/**
 * 极光推送 保存相关数据
 */
public class JgPush {

    private Context context;
    private Handler handler;
    private String jpush_url = "JGpush.save";

    public JgPush(Context context, String regId) {
        this.context = context;
        handler();
        setRegId(regId);
    }

    private void handler() {
        handler = new Handler() {
            @Override
            public void handleMessage(Message msg) {
                super.handleMessage(msg);
                //这里不做结果的操作
            }
        };
    }

    /**
     * 存储极光ID
     */
    public void setRegId(String regId) {
        Map<String, String> map = new HashMap<String, String>();
        map.put("user_id", AppConst.getUser().getId());
        map.put("regid", regId);
        new OkhttpClientTest().path(context, handler, jpush_url, map, HttpCode.JPUSH_REGID);
    }

}
